Mini-Project #03: Visualizing and Maintaining the Green Canopy of NYC

TASK 1: DOWNLOAD NYC CITY COUNCIL DISTRICT BOUNDARIES

We’ll begin by downloading data from the NYC Department of Planning site. It contains the boundaries of the 51 Council Districts that make up NYC, along with its geometry, allowing us to plot them and create maps. The following is a function used to respectfully retrieve the data from the NYC Open Data.

Show the code
library(httr)
library(jsonlite)
library(sf)
library(dplyr)
library(sf)
library(kableExtra)

#CREATES THE FUNCTION download_boundaries TO ACQUIRE DATA, DOES NOT TAKE PARAMETERS
download_boundaries <- function(){
  
  #CREATES FOLDER mp03 WITHIN data, IF NEEDED
  if(!dir.exists(file.path("data", "mp03"))){
    dir.create(file.path("data", "mp03"), showWarnings=FALSE, recursive=TRUE)
  }
  
  #DOWNLOADS ZIP FILE, IF NEEDED
  url = "https://s-media.nyc.gov/agencies/dcp/assets/files/zip/data-tools/bytes/city-council/nycc_25c.zip"
  destfile <- "data/mp03/nycc_25.zip"
  
  if(!file.exists(destfile)){
    download.file(url, destfile = destfile, mode="wb")
  }
  
  #UNZIPS FILE, IF NEEDED
  unzipped_dir <- "data/mp03/nycc_25"
  if (!dir.exists(unzipped_dir)) {
  unzip(destfile, exdir = unzipped_dir)
  }
  
  #READ IN SHP FILE
  nyc_boundaries <- st_read("data/mp03/nycc_25/nycc_25c")
  
  #TRANSFORM shp file TO WGS 84
  nyc_boundaries_wgs84 <- st_transform(nyc_boundaries, crs = "WGS84")
}

nyc <- download_boundaries()

#CHANGING INTO DATAFRAMES FOR SHORTER RENDERING TIME
nyc_df <- as.data.frame(nyc)

TASK 2: DOWNLOAD TREE POINTS

Focusing on NYC’s green spaces, we will need tree points data sourced from NYC Forestry Tree Points from NYC OpenData. The following function utilizes a while loop to respectfulling and efficiently retrieve all 1+ million observations are recorded.

Show the code
download_trees <- function() {
  # API URL
  api_url <- "https://data.cityofnewyork.us/resource/hn5i-inap.json"
  
  # PARAMETERS
  limit <- 10000
  offset <- 0
  all_data <- list()
  
  # Get total count of rows
  count_url <- paste0(api_url, "?$select=count(*)")
  count_response <- GET(count_url)
  count_text <- content(count_response, "text", encoding = "UTF-8")
  total_rows <- as.numeric(fromJSON(count_text)$count)
  message("Total rows to fetch: ", total_rows)
  
  #COLUMNS TO KEEP
  keep_cols <- c(
    "objectid", "dbh", "tpstructure", "tpcondition", "stumpdiameter",
    "plantingspaceglobalid", "geometry", "globalid", "genusspecies",
    "createddate", "updateddate", "planteddate",
    "riskrating", "riskratingdate", "location"
  )
  
  #LOOPS THROUGH TO OBTAIL ALL OBSERVATIONS
  while (offset < total_rows) {
    query_url <- paste0(api_url, "?$limit=", limit, "&$offset=", offset)
    message("Downloading offset ", offset, " ...")
    
    response <- GET(query_url)
    txt <- content(response, "text", encoding = "UTF-8")
    
    #PARSING
    page_data <- tryCatch(fromJSON(txt, flatten = TRUE), error = function(e) NULL)
    if (is.null(page_data) || nrow(page_data) == 0) break
    
    #KEEPING SPECIFIED COLUMNS
    page_data <- page_data[, intersect(names(page_data), keep_cols), drop = FALSE]
    
    #APPEND
    all_data[[length(all_data) + 1]] <- page_data
    
    #GIVE API A QUICK REST INBETWEEN
    offset <- offset + limit
    Sys.sleep(0.3) 
    
    options(scipen=999)
  }
  
  # COMBINE
  tree_data <- bind_rows(all_data)
  
  # SAVE TO CSV
  dir.create("data/mp03", recursive = TRUE, showWarnings = FALSE)
  write.csv(tree_data, "data/mp03/nyc_trees_clean.csv", row.names = FALSE)
  
  return(tree_data)
}


tree <- download_trees()

#OVERVIEW OF tree_data
#ISSUE: geometry type is characters instead of geompoints
summary(tree)

#CREATE tree_sf TO HAVE GEOMETRY POINTS
tree_sf <- tree %>%
  mutate(geometry = st_as_sfc(geometry, crs = 4326)) %>%  
  st_as_sf()

#OVERVIEW OF tree_sf, GOOD TO GO FOR MAPPING
summary(tree_sf)

#TURNS tree_sf INTO DATAFRAME FOR FASTER RENDERING
tree_sf_df <- as.data.frame(tree_sf)

TASK 3: PLOT ALL TREE POINTS

Both datasets contain geographic coordinates that can be visualized on a map. Plotting the Council District boundaries will give us the base. By overlaying the tree point data, we can observe the distribution of greenery throughout NYC.

Show the code
library(ggplot2)

ggplot() +
  geom_sf(data = nyc, mapping=aes(), color = "black") + #NYC COUNCIL DISTRICT MAP
  geom_sf(data = tree_sf_df$geometry, color = "darkgreen", mapping=aes(), size = 0.05, alpha = 0.2) + #TREE POINTS
  scale_fill_viridis_c() +
  theme_minimal() +
  labs(
    title = "NYC Tree Points within Council District Boundaries",
    caption = "Source: NYC OpenData"
  )

ZOOM IN FOR A CLOSER LOOK

Show the code
library(leaflet)

leaflet() |>
  addTiles() |>
  addPolygons(data = nyc, color = "black", fill = FALSE) |>
  addCircleMarkers(data = tree_sf, radius = 2, color = "forestgreen", stroke = FALSE, fillOpacity = 0.5)

TASK 4: DISTRICT-LEVEL ANALYSIS OF TREE COVERAGE

Using these geographic coordinates we could join the datasets for further analysis. By doing so, we can locate the district of where certain tree species are located, adding meaning to our findings.

Show the code
#JOINS COUNCIL DISTRICT BOUNDARIES AND TREE POINTS BY FINDING ALL THE POINTS THAT LIE WITHIN THE MULTIPOLYGON OF EACH COUNCIL DISTRICT 
nyc_trees <- st_join(nyc, tree_sf)

nyc_trees_df <- as.data.frame(nyc_trees)
Show the code
#1. Which council district has the most trees? 
tree_count <- nyc_trees_df |>
  group_by(CounDist) |>
  summarize(total_trees = n()) |>
  arrange(desc(total_trees))

NYC Tree Counts by Council District

Council District 51 has the most trees, with a total of 70,965.

Show the code
kable(tree_count) |>
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) |>
  scroll_box(height = "400px") |>
  row_spec(which.max(tree_count$total_trees), background = "forestgreen", color = "white")
CounDist total_trees
51 70965
50 52500
19 49940
23 44917
13 36665
49 35117
39 32403
31 31321
32 30270
27 29395
11 27854
24 26287
28 25544
46 24330
30 23012
47 21340
20 20717
29 19994
42 18935
33 18861
21 18791
17 18589
15 18422
48 18237
8 18196
22 17973
44 17641
45 17267
18 17132
38 16521
12 16168
34 15875
7 15648
37 15637
26 15380
10 15309
35 15109
41 14416
16 13497
36 13472
9 13455
1 12259
6 12139
3 12002
40 11934
2 11563
4 11095
14 10905
43 10532
25 10166
5 8326



Show the code
#2. Which council district has the highest density of trees? The Shape_Area column from the district shape file will be helpful here.
density <- nyc_trees_df |>
  group_by(CounDist, Shape_Area) |>
  summarize(total_trees = n(), .groups = "drop") |>
  ungroup() |>
  mutate(tree_density = total_trees/Shape_Area) |>
  arrange(desc(tree_density))

Tree Density by Council District

Council District 7 has the highest density of tree density of 0.0002835 trees per squared fit.

Show the code
kable(density) |>
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) |>
  scroll_box(height = "400px") |>
  row_spec(which.max(density$tree_density), background = "forestgreen", color = "white")
CounDist Shape_Area total_trees tree_density
7 55186140 15648 0.0002835
39 118294553 32403 0.0002739
2 48322121 11563 0.0002393
9 56263769 13455 0.0002391
5 37752246 8326 0.0002205
16 62082481 13497 0.0002174
14 52585062 10905 0.0002074
10 76997844 15309 0.0001988
35 79440619 15109 0.0001902
41 79271987 14416 0.0001819
15 102495308 18422 0.0001797
44 99194858 17641 0.0001778
36 76224396 13472 0.0001767
33 110198297 18861 0.0001712
8 106989876 18196 0.0001701
4 66802515 11095 0.0001661
48 109815036 18237 0.0001661
40 73666390 11934 0.0001620
17 115113830 18589 0.0001615
25 63861388 10166 0.0001592
3 76315832 12002 0.0001573
1 78106503 12259 0.0001570
29 127849354 19994 0.0001564
18 110601770 17132 0.0001549
37 101031674 15637 0.0001548
34 105180459 15875 0.0001509
19 334738191 49940 0.0001492
6 82672687 12139 0.0001468
45 117904762 17267 0.0001464
28 175137630 25544 0.0001459
47 147530657 21340 0.0001446
23 311520682 44917 0.0001442
21 130912211 18791 0.0001435
20 144833269 20717 0.0001430
24 186824791 26287 0.0001407
43 75477511 10532 0.0001395
27 210809911 29395 0.0001394
30 168734193 23012 0.0001364
11 216987852 27854 0.0001284
12 131040796 16168 0.0001234
22 150395658 17973 0.0001195
13 328361699 36665 0.0001117
38 151771974 16521 0.0001089
51 657989092 70965 0.0001079
49 330301028 35117 0.0001063
42 201334162 18935 0.0000940
26 168180998 15380 0.0000914
46 277719690 24330 0.0000876
32 358667790 30270 0.0000844
50 665196534 52500 0.0000789
31 507654144 31321 0.0000617



Show the code
#3. Which district has highest fraction of dead trees out of all trees?
dead_trees <- nyc_trees_df |>
  group_by(CounDist) |>
  summarize(total_trees = n(),
           dead_count = sum(tpcondition == "Dead", na.rm=TRUE)) |>
  mutate(fraction_of_dead_trees = dead_count/total_trees) |>
  arrange(desc(fraction_of_dead_trees))

Fraction of Dead Trees by Council District

Council District 32 has the highest fraction of dead trees of 0.14, shown in red Although Council District 51 has the highest count of dead trees, shown in yellow.

Show the code
kable(dead_trees) |>
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) |>
  scroll_box(height = "400px") |>
  row_spec(which.max(dead_trees$fraction_of_dead_trees), background = "tomato", color = "white") |>
  row_spec(which.max(dead_trees$dead_count), background = "yellow", color = "black")
CounDist total_trees dead_count fraction_of_dead_trees
32 30270 4315 0.1425504
30 23012 3231 0.1404050
2 11563 1576 0.1362968
50 52500 7087 0.1349905
29 19994 2688 0.1344403
16 13497 1782 0.1320293
23 44917 5900 0.1313534
49 35117 4584 0.1305351
11 27854 3627 0.1302147
20 20717 2697 0.1301829
51 70965 9198 0.1296132
19 49940 6391 0.1279736
14 10905 1359 0.1246217
24 26287 3265 0.1242059
13 36665 4540 0.1238238
27 29395 3626 0.1233543
28 25544 3121 0.1221813
17 18589 2241 0.1205552
1 12259 1468 0.1197488
5 8326 994 0.1193851
15 18422 2186 0.1186625
22 17973 2114 0.1176209
4 11095 1294 0.1166291
25 10166 1185 0.1165650
3 12002 1346 0.1121480
31 31321 3428 0.1094473
9 13455 1459 0.1084355
10 15309 1643 0.1073225
12 16168 1676 0.1036616
34 15875 1611 0.1014803
8 18196 1846 0.1014509
26 15380 1528 0.0993498
7 15648 1544 0.0986708
18 17132 1688 0.0985291
6 12139 1069 0.0880633
38 16521 1424 0.0861933
37 15637 1314 0.0840315
21 18791 1531 0.0814752
48 18237 1483 0.0813182
47 21340 1718 0.0805061
42 18935 1479 0.0781093
33 18861 1418 0.0751816
45 17267 1285 0.0744194
39 32403 2395 0.0739129
40 11934 879 0.0736551
44 17641 1261 0.0714812
35 15109 1055 0.0698259
43 10532 721 0.0684580
41 14416 979 0.0679107
36 13472 867 0.0643557
46 24330 1462 0.0600904



Show the code
#4. What is the most common tree species in Manhattan? 
manhattan_species <- nyc_trees_df |>
  filter(CounDist >= 1, CounDist<=10) |>
  group_by(genusspecies) |>
  summarize(total_trees = n()) |>
  arrange(desc(total_trees))


Counts of Tree Species Found in Manhattan

Manhattan has 458 unique trees species throughout Council District 1 to 10. The most common one you’ll spot is the Gleditsia triacanthos var. inermis - Thornless honeylocust, better known as Honey locust.

Show the code
kable(manhattan_species) |>
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) |>
  scroll_box(height = "400px") |>
  row_spec(which.max(manhattan_species$total_trees), background = "forestgreen", color = "white")
genusspecies total_trees
Gleditsia triacanthos var. inermis - Thornless honeylocust 17310
Platanus x acerifolia - London planetree 11593
Pyrus calleryana - Callery pear 8793
Quercus palustris - pin oak 8107
Ginkgo biloba - maidenhair tree 7462
Zelkova serrata - Japanese zelkova 5771
Styphnolobium japonicum - Japanese pagoda tree 5436
Tilia cordata - littleleaf linden 4417
Unknown - Unknown 3758
Ulmus americana - American elm 3523
Quercus rubra - northern red oak 2463
Tilia americana - American basswood 2091
Quercus bicolor - swamp white oak 1949
Prunus - Cherry 1634
Malus - apple 1583
Quercus phellos - willow oak 1527
Gymnocladus dioicus - Kentucky coffeetree 1420
Liquidambar styraciflua - sweetgum 1280
Celtis occidentalis - common hackberry 1248
Morus - mulberry 1190
Ulmus pumila - Siberian elm 1190
Prunus serrulata 'Green leaf' - 'Green leaf' Japanese flowering cherry 1144
Acer rubrum - red maple 1113
Crataegus - Hawthorn 1065
Ulmus parvifolia - Chinese elm 999
Acer platanoides - Norway maple 963
Fraxinus pennsylvanica - Green ash 962
Tilia tomentosa - silver linden 956
Cercis canadensis - eastern redbud 950
Robinia pseudoacacia - black locust 915
Metasequoia glyptostroboides - dawn redwood 851
Quercus acutissima - sawtooth oak 847
Carpinus betulus - European hornbeam 785
Koelreuteria paniculata - goldenrain tree 771
Zelkova serrata 'Green Vase' - 'Green Vase' Zelkova 641
Quercus - Oak 611
Quercus imbricaria - shingle oak 598
Gleditsia triacanthos var. inermis 'Skyline' - 'Skyline' Thornless honeylocust 597
Prunus serotina - black cherry 539
Ailanthus altissima - tree of heaven 479
Quercus coccinea - scarlet oak 475
Eucommia ulmoides - Hardy Rubber Tree 463
Prunus cerasifera - cherry plum 454
Acer - maple 449
Cornus florida - flowering dogwood 437
Juniperus virginiana - eastern redcedar 432
Quercus shumardii - Shumard's oak 378
Ulmus americana 'Princeton' - 'Princeton' American elm 376
Tilia tomentosa 'Sterling' - 'Sterling' Silver linden 351
Quercus macrocarpa - bur oak 350
Magnolia - magnolia 347
Platanus x acerfolia 'Exclamation' - 'Exclamation' London planetree 344
Betula nigra - river birch 339
Taxodium distichum - bald cypress 338
Carpinus caroliniana - American hornbeam 333
Quercus alba - white oak 328
Maackia amurensis - Amur maackia 324
Tilia americana 'Redmond' - 'Redmond' American linden 303
Platanus x acerifolia 'Bloodgood' - 'Bloodgood' London planetree 292
Gymnocladus dioicus 'Espresso' - 'Espresso' Kentucky coffee tree 270
Quercus robur - English oak 266
Quercus ellipsoidalis - northern pin oak 258
Pinus strobus - eastern white pine 252
Syringa reticulata - Japanese tree lilac 248
Amelanchier - serviceberry 238
Cornus kousa - kousa dogwood 234
Liriodendron tulipifera - tuliptree 224
Styphnolobium japonicum 'Millstone' - 'Millstone' Japanese pagodatree 223
Prunus serrulata 'Not Green leaf' - 'Not Green leaf' Japanese flowering cherry 210
Cornus mas - Cornelian cherry 201
Cladrastis kentukea - Kentucky yellowwood 198
Acer campestre - hedge maple 183
Pinus - pine 180
Ilex - holly 178
Zelkova serrata 'Village Green' - 'Village Green' Zelkova 178
Quercus velutina - black oak 173
Gleditsia triacanthos - Honeylocust 170
Lagerstroemia - lagerstroemia 160
Tilia x. europaea - Common linden 158
Fraxinus - Ash 155
Acer pseudoplatanus - sycamore maple 147
Quercus muehlenbergii - chinkapin oak 146
Tilia cordata 'Greenspire' - 'Greenspire' Littleleaf linden 143
Ostrya virginiana - hophornbeam 135
Ginkgo biloba 'Magyar' - 'Magyar' Ginkgo 134
Zelkova serrata 'Mushashino' - 'Mushashino' Zelkova 132
Malus floribunda - Japanese flowering crabapple 131
Acer saccharinum - silver maple 127
Platanus occidentalis - American sycamore 122
Gleditsia triacanthos var. inermis 'Imperial' - 'Imperial' Thornless honeylocust 119
Parrotia persica - Persian ironwood 119
Amelanchier canadensis - Canadian serviceberry 116
Ulmus 'Patriot' - 'Patriot' Elm 115
Acer x freemanii - Freeman maple 107
Fraxinus americana - white ash 103
Styphnolobium japonicum 'Regent' - 'Regent' Japanese pagodatree 101
Betula papyrifera - paper birch 100
Tilia americana 'McSentry' - 'McSentry' American linden 100
Tilia mongolica 'Harvest Gold' - 'Harvest Gold' Mongolian linden 99
Ilex opaca - American holly 98
Liquidambar styraciflua 'Moraine' - 'Moraine' Sweetgum 98
Ginkgo biloba 'Autumn Gold' - 'Autumn Gold' Ginkgo 95
Populus deltoides - eastern cottonwood 95
Acer saccharum - sugar maple 94
Acer x freemanii 'Autumn Blaze' - 'Autumn Blaze' Freeman maple 94
Nyssa sylvatica - blackgum 94
Platanus x acerifolia 'Columbia' - 'Columbia' London planetree 94
Ulmus parvifolia 'Allee' - 'Allee' Chinese elm 93
Pinus resinosa - red pine 91
Salix babylonica - Weeping willow 90
Ulmus 'Frontier' - 'Frontier' Elm 88
Prunus serrulata 'Kwanzan' - 'Kwanzan' Flowering cherry 84
Gleditsia triacanthos var. inermis 'Streetkeeper' - 'Streetkeeper' Thornless honeylocust 81
Ulmus 'New Horizon' - 'New Horizon' Elm 81
Catalpa - catalpa 80
Cercidiphyllum japonicum - katsura tree 80
Thuja occidentalis - arborvitae 79
Tilia x. euchlora - Caucasian linden 79
Aesculus hippocastanum - horse chestnut 78
Cryptomeria japonica - Japanese cedar 75
Acer rubrum 'October Glory' - 'October Glory' Red maple 73
Acer platanoides 'Crimson King' - 'Crimson King' Norway maple 71
Quercus lyrata - overcup oak 69
Ulmus 'Homestead' - 'Homestead' Elm 69
Fagus grandifolia - American beech 68
Carpinus betulus 'Fastigiata' - 'Fastigiata' European hornbeam 66
Picea - spruce 66
Catalpa speciosa - northern catalpa 65
Betula nigra 'Heritage' - 'Heritage' River birch 64
Acer palmatum - Japanese maple 63
Carpinus betulus 'Emerald Avenue' - 'Emerald Avenue' European hornbeam 62
Populus tremuloides - quaking aspen 58
Taxus baccata - English yew 58
Nyssa sylvatica 'Wildfire' - 'Wildfire' Black gum 57
Pinus rigida - pitch pine 57
Tilia americana 'Boulevard' - 'Boulevard' American linden 57
Malus hupehensis - Chinese crabapple 56
Syringa reticulata 'Ivory Silk' - 'Ivory Silk' Japanese tree lilac 56
Crataegus crus-galli var. inermis - Cockspur hawthorn 55
Quercus 'Regal Prince' - 'Regal Prince' Oak 53
Acer ginnala - Amur maple 52
Betula pendula - European white birch 51
Cedrus deodara - Deodar cedar 51
Ginkgo biloba 'Princeton Sentry' - 'Princeton Sentry' Ginkgo 51
Picea pungens - blue spruce 51
Amelanchier arborea - common serviceberry 50
Paulownia tomentosa - princesstree 50
Amelanchier laevis - Allegheny serviceberry 49
Prunus serrulata - Japanese flowering cherry 49
Corylus colurna - Turkish hazelnut 48
Juniperus chinensis - Chinese juniper 48
Zelkova serrata 'City Sprite' - 'City Sprite' Zelkova 48
Acer rubrum 'Redpointe' - 'Redpointe' Red maple 47
Chamaecyparis thyoides - Atlantic white cedar 47
Phellodendron amurense - Amur corktree 46
Prunus virginiana - chokecherry 45
Cedrus atlantica - Atlas cedar 43
Taxodium distichum 'Shawnee Brave' - 'Shawnee Brave' Bald cypress 42
Gleditsia triacanthos var. inermis 'Halka' - 'Halka' Thornless honeylocust 40
Ulmus 'Triumph' - 'Triumph' Elm 40
Ulmus propinqua 'Emerald Sunshine' - 'Emerald Sunshine' Elm 40
Acer miyabei 'State Street' - 'State Street' Miyabe maple 39
Prunus virginiana 'Canada Red' - 'Canada Red' Chokecherry 39
Acer rubrum 'Frank Jr.' - 'Frank Jr.' red maple 36
Tsuga canadensis - eastern hemlock 36
Acer griseum - paperbark maple 35
Acer rubrum 'Autumn Blaze' - 'Autumn Blaze' Red maple 35
Maclura pomifera - osage orange 35
Koelreuteria paniculata 'Gold Candle' - 'Gold Candle' Goldenraintree 34
Styrax japonicus - Japanese snowbell 34
Tilia tomentosa 'Silver Lining' - 'Silver Lining' Silver linden 34
Zelkova serrata 'Wireless' - 'Wireless' Zelkova 34
Celtis occidentalis 'Praire Sentinal' - 'Praire Sentinal' Hackberry 33
Fagus sylvatica - European beech 33
Malus ioensis - prairie crabapple 32
Pseudotsuga menziesii - Douglas-fir 32
Sassafras albidum - sassafras 31
Chionanthus retusus - Chinese fringetree 29
Carpinus japonica - Japanese hornbeam 28
Magnolia grandiflora - southern magnolia 28
Aesculus x carnea - red horse-chestnut 27
Prunus persica - Peach 27
Prunus x yedoensis - Yoshino cherry 27
Cotinus coggygria - European smoketree 26
Crataegus viridis 'Winter King' - 'Winter King' Green hawthorn 26
Gleditsia triacanthos var. inermis 'Northern Acclaim' - 'Northern Acclaim' Thornless honeylocust 26
Acer rubrum 'Red Sunset' - 'Red Sunset' Red maple 25
Hamamelis virginiana - American witchhazel 25
Metasequoia glyptostroboides 'Gold Rush' - 'Gold Rush' Dawn redwood 25
Picea glauca - white spruce 25
Picea abies - Norway spruce 24
Ginkgo biloba 'Windover Gold' - 'Windover Gold' Ginkgo 23
Quercus montana - Chestnut oak 23
Quercus palustris 'Green Pillar' - 'Green Pillar' Pin oak 23
Parrotia persica 'Ruby Vase' - 'Ruby Vase' Persian ironwood 22
Amelanchier 'Autumn Brilliance' - 'Autumn Brilliance' Serviceberry 21
Halesia carolina - Carolina silverbell 21
Juglans nigra - black walnut 21
Liquidambar styraciflua 'Slender Silhouette' - 'Slender Silhouette' Sweetgum 21
Syringa pekinensis - Peking tree lilac 21
Ulmus x - Hybrid Elm 21
Acer saccharum 'Commemoration' - 'Commemoration' Sugar maple 20
Carya cordiformis - bitternut hickory 20
Taxodium ascendens - pond cypress 20
Acer truncatum 'Urban Sunset' - 'Urban Sunset' Shantung maple 19
Betula populifolia - gray birch 19
Liquidambar styraciflua 'Happidaze' - 'Happidaze' Sweetgum 19
Tilia platyphyllos - largeleaf linden 19
Ulmus 'Athena' - 'Athena' Elm 19
Acer rubrum 'Armstrong' - 'Armstrong' Red maple 18
Carya glabra - pignut hickory 18
Malus 'Royal Raindrops' - 'Royal Raindrops' Crabapple 18
Ulmus minor 'Atinia' - English elm 18
Acer truncatum - Shantung maple 17
Celtis occidentalis 'Chicagoland' - 'Chicagoland' Hackberry 17
Magnolia virginiana - sweetbay 17
Prunus 'Okame' - 'Okame' Cherry 17
Prunus subhirtella 'Pendula' - 'Pendula' Higan cherry 17
Pinus nigra - Austrian pine 16
Taxodium ascendens 'Morris Debonair' - 'Morris Debonair' Bald cypress 16
NA 16
Celtis australis - European hackberry 15
Cornus alternifolia - alternateleaf dogwood 15
Malus 'Adams' - 'Adams' Crabapple 15
Malus 'Velvet Pillar' - 'Velvet Pillar' flowering crabapple 15
Ilex x 'Nellie R. Stevens' - 'Nellie R. Stevens' Holly 14
Juniperus virginiana 'Glauca' - 'Glauca' Eastern red cedar 14
Prunus cerasifera 'Newport' - 'Newport' Cherry plum 14
Salix spp. - Willow 14
Thuja 'Green Giant' - 'Green Giant' Arborvitae 14
Zelkova serrata 'Halka' - 'Halka' Zelkova 14
Aesculus glabra - Ohio buckeye 13
Chamaecyparis pisifera - sawara-cypress 13
Acer tataricum - tatarian maple 12
Aesculus sp. - Horsechestnut 12
Aesculus x carnea 'Fort Mcnair' - 'Fort Mcnair' Ruby red horsechestnut 12
Quercus robur var. fastigiata - Upright english oak 12
Acer negundo - boxelder 11
Magnolia acuminata - cucumber tree 11
Quercus falcata - southern red oak 11
Syringa pekinensis 'Summer Charm' - 'Summer Charm' Peking lilac 11
Tilia americana 'Continental Appeal' - 'Continental Appeal' American linden 11
Tilia cordata 'Glenlevyn' - 'Glenlevyn' Littleleaf linden 11
Abies alba - silver fir 10
Acer campestre 'Metro Gold' - 'Metro Gold' Hedge maple 10
Cercis reniformis - Oklahoma redbud 10
Chionanthus virginicus - Fringetree 10
Ginkgo biloba 'Presidential Gold' - 'Presidential Gold' Ginkgo 10
Ilex aquifolium - English holly 10
Lagerstroemia indica - Crape Myrtle 10
Magnolia stellata - star magnolia 10
Pinus heldreichii - Bosnian Pine 10
Cornus controversa 'June Snow' - 'June Snow' dogwood 9
Juniperus chinensis 'Hetzii' - 'Hetzii' Chinese juniper 9
Malus 'Harvest Gold' - 'Harvest Gold' Crabapple 9
Prunus padus 'Merlot' - 'Merlot' European bird cherry 9
Prunus subhirtella 'Autumnalis' - 'Autumnalis' Higan cherry 9
Quercus phellos 'Hightower' - 'Hightower' Willow oak 9
Salix alba - white willow 9
Ulmus 'Accolade' - 'Accolade' Elm 9
Acer platanoides 'Not Green Leaf' - 'Not Green Leaf' Norway maple 8
Acer rubrum 'Brandywine' - 'Brandywine' Red maple 8
Albizia julibrissin - silktree 8
Cryptomeria japonica 'Yoshino' - 'Yoshino' Japanese cedar 8
Ginkgo biloba 'Columnar' - 'Columnar' Ginkgo 8
Lagerstroemia 'Natchez' - 'Natchez' Crapemyrtle 8
Malus 'Red Jewel' - 'Red Jewel' Crabapple 8
Malus sargentii - Sargent's apple 8
Nyssa sylvatica 'Red Rage' - 'Red Rage' Black gum 8
Prunus serrulata 'Royal Burgundy' - 'Royal Burgundy' Flowering cherry 8
Robinia pseudoacacia 'Frisia' - 'Frisia' Black locust 8
Styrax obassia - Fragrant snowbell 8
Ulmus americana 'Valley Forge' - 'Valley Forge' American Elm 8
Asimina triloba – Pawpaw 7
Betula platyphylla - Asian white birch 7
Chamaecyparis obtusa 'Crippsii' - 'Crippsii' Golden hinoki cypress 7
Diospyros virginiana - common persimmon 7
Ginkgo biloba 'Shangri La' - 'Shangri La' Ginkgo 7
Magnolia x. soulangiana 'Rustica Rubra' - 'Rustica Rubra' Saucer magnolia 7
Malus 'Prariefire' - 'Prariefire' Crabapple 7
Picea omorika - Serbian spruce 7
Pinus strobiformis - southwestern white pine 7
Prunus cerasifera 'Thundercloud' - 'Thundercloud' Cherry plum 7
Prunus x yedoensis 'Akebono' - 'Akebono' Yoshino cherry 7
Quercus cerris - European turkey oak 7
Quercus palustris 'Pacific Brilliance' - 'Pacific Brilliance' Pin oak 7
Rhus glabra - Smooth Sumac 7
Tilia cordata 'Corinthian' - 'Corinthian' Littleleaf linden 7
Ulmus 'New Harmony' - 'New Harmony' Elm 7
Abies balsamea - balsam fir 6
Acer buergerianum - trident maple 6
Betula nigra 'Duraheat' - 'Duraheat' River birch 6
Carya - Hickory 6
Castanea mollissima - Chinese chestnut 6
Chamaecyparis lawsoniana - Port Orford cedar 6
Cornus florida 'Cherokee Brave' - 'Cherokee Brave' Flowering dogwood 6
Koelreuteria paniculata 'Fastigiata' - 'Fastigiata' Goldenraintree 6
Liquidambar styraciflua 'Worplesdon' - 'Worplesdon' Sweetgum 6
Malus 'Donald Wyman' - 'Donald Wyman' Crabapple 6
Picea orientalis - Oriental spruce 6
Populus grandidentata - bigtooth aspen 6
Prunus 'Mt Fuji' - 'Mt Fuji' Cherry 6
Prunus x hillieri 'Spires' - 'Spires' Flowering cherry 6
Pyrus calleryana 'Chanticleer' - 'Chanticleer' Callery pear 6
Quercus laurifolia - laurel oak 6
Quercus macrocarpa 'Urban Pinnacle' - 'Urban Pinnacle' bur oak 6
Quercus x macdanielli 'Heritage' - 'Heritage' Oak 6
Stewartia pseudocamellia - Japanese stewartia 6
Styrax japonicus 'Snowcone' - 'Snowcone' Japanese snowbell 6
Ulmus parvifolia 'Dynasty' - 'Dynasty' Chinese elm 6
Amelanchier canadensis 'Robin Hill' - 'Robin Hill' Canadian serviceberry 5
Betula alleghaniensis - yellow birch 5
Betula lenta - sweet birch 5
Cornus mas 'Golden Glory' - 'Golden Glory' Cornelian cherry dogwood 5
Elaeagnus angustifolia - Russian olive 5
Larix laricina - tamarack 5
Magnolia 'Galaxy' - 'Galaxy' Magnolia 5
Prunus cerasifera 'Crimson Point' - 'Crimson Point' Cherry plum 5
Ulmus 'Morton Glossy' - 'Morton Glossy' Elm 5
Acer rubrum 'New World' - 'New World' Red maple 4
Aesculus hippocastanum 'Baumanni' - 'Baumanni' Horsechestnut 4
Alnus glutinosa - European alder 4
Amelanchier x intermedia - serviceberry 4
Aralia spinosa - devil's walkingstick 4
Cercis canadensis 'Appalachian Red' - 'Appalachian Red' Eastern redbud 4
Corylus americana - American hazelnut 4
Crataegus phaenopyrum 'Washington' - 'Washington' Hawthorn 4
Fraxinus pennsylvanica 'Leprechaun' - 'Leprechaun' Green ash 4
Ginkgo biloba 'Fairmont' - 'Fairmont' Ginkgo 4
Gleditsia triacanthos var. inermis 'Shademaster' - 'Shademaster' Thornless honeylocust 4
Hamamelis x intermedia 'Diane' - 'Diane' Witch hazel 4
Liquidambar styraciflua 'Cherokee' - 'Cherokee' Sweetgum 4
Magnolia x soulangiana - Chinese magnolia 4
Pinus thunbergii - Japanese black pine 4
Pistacia chinensis - Chinese pistache 4
Prunus 'Snow Goose' - 'Snow Goose' Cherry 4
Prunus avium - Sweet Cherry 4
Prunus sargentii - Sargent cherry 4
Pyrus calleryana 'Aristocrat' - 'Aristocrat' Callery pear 4
Ulmus 'Jefferson' - 'Jefferson' Elm 4
Ulmus wilsoniana 'Prospector' - 'Prospector' Elm 4
Abies concolor - white fir 3
Acer japonicum - Amur maple 3
Acer nigrum - black maple 3
Acer truncatum 'Pacific Sunset' - 'Pacific Sunset' Shangtung maple 3
Carya illinoinensis - pecan 3
Catalpa bignonioides - southern catalpa 3
Cercis canadensis 'Forest Pansy' - 'Forest Pansy' Eastern redbud 3
Cornus 'Venus' - 'Venus' Dogwood 3
Ficus carica - Common Fig 3
Heptacodium miconioides - seven-son flower 3
Koelreuteria paniculata 'Rose Lanterns' - 'Rose Lanterns' Goldenraintree 3
Maackia amurensis 'Starburst' - 'Starburst' Amur Maackia 3
Maclura pomifera 'White Shield' - 'White Shield' Osage orange 3
Magnolia kobus - Kobus magnolia 3
Magnolia macrophylla - bigleaf magnolia 3
Malus 'Perfect Purple' - 'Perfect Purple' flowering crabapple 3
Malus 'Spring Snow' - 'Spring Snow' Crabapple 3
Pinus flexilis 'Vanderwolf' - 'Vanderwolf' Limber pine 3
Pinus virginiana - Virginia pine 3
Quercus bicolor 'American Dream' - 'American Dream' Swamp white oak 3
Robinia hispida - bristly locust 3
Syringa pekinensis 'Bejing Gold' - 'Bejing Gold' Peking lilac 3
Tilia americana 'Legend' - 'Legend' American linden 3
Tilia tomentosa 'Szeleste' - 'Szeleste' Silver linden 3
Ulmus parvifolia 'Everclear' - 'Everclear' Chinese elm 3
Acer truncatum 'Crimson Sunset' - 'Crimson Sunset' Shangtung maple 2
Acer truncatum 'Norwegian Sunset' - 'Norwegian Sunset' Shangtung maple 2
Aesculus pavia - red buckeye 2
Aesculus x carnea 'Briotii' - 'Briotii' Ruby red horsechestnut 2
Carya ovata - shagbark hickory 2
Castanea dentata - American chestnut 2
Cedrus atlantica 'Glauca' - Blue Atlas cedar 2
Cercis canadensis 'Columbus' - 'Columbus' Eastern redbud 2
Cercis canadensis var. Alba - White redbud 2
Cornus nuttallii - Pacific dogwood 2
Cryptomeria japonica 'Angelica' - 'Angelica' Japanese cedar 2
Halesia diptera - Two-wing silverbell 2
Laburnum x watereri - golden chain tree 2
Lagerstroemia indica 'Muskogee' - 'Muskogee' Crapemyrtle 2
Magnolia 'Butterflies' - 'Butterflies' Magnolia 2
Magnolia loebneri 'Dr. Merril' - 'Dr. Merril' Loebner magnolia 2
Malus 'Cardinal' - 'Cardinal' Crabapple 2
Malus 'Sugartyme' - 'Sugartyme' Crabapple 2
Malus sargentii 'Tina' - 'Tina' Sargent's crabapple 2
Pinus flexilis - limber pine 2
Pinus mugo - Mountain Pine 2
Pinus sylvestris - Scots pine 2
Pinus wallichiana - Bhutan pine 2
Prunus padus - European birdcherry 2
Pseudolarix amabilis - Golden Larch 2
Pyrus calleryana 'Cleveland Select' - 'Cleveland Select' Callery pear 2
Pyrus calleryana 'Holmford' - 'Holmford' Callery pear 2
Pyrus calleryana 'Stone Hill' - 'Stone Hill' Callery pear 2
Pyrus fauriei 'Korean Sun' - 'Korean Sun' Pear 2
Quercus bicolor 'Beacon' - 'Beacon' Swamp white oak 2
Quercus ilex - holly oak 2
Robinia pseudoacacia 'Purple Robe' - 'Purple Robe' Black locust 2
Salix x pendulina - Wisconsin Weeping Willow 2
Sorbus americana - American mountain ash 2
Sorbus aucuparia - European mountain ash 2
Thuja plicata - western redcedar 2
Vitex agnus-castus - lilac chastetree 2
Zelkova serrata 'Kiwi Sunset' - 'Kiwi Sunset' Zelkova 2
Acer ginnala 'Flame' - 'Flame' Amur maple 1
Acer pensylvanicum - striped maple 1
Acer rubrum 'Karpick' - 'Karpick' Red maple 1
Acer rubrum 'Sun valley' - 'Sun valley' Red maple 1
Acer saccharum 'Green Mountain' - 'Green Mountain' Sugar maple 1
Acer tataricum 'Hot Wings' - 'Hot Wings' Tatarian maple 1
Acer x freemanii 'Scarsen' - 'Scarsen' Freeman maple 1
Aesculus octandra - Yellow buckeye 1
Aesculus parviflora - bottlebrush buckeye 1
Carpinus betulus 'Lucas' - 'Lucas' European hornbeam 1
Carpinus caroliniana 'Native Flame' - 'Native Flame' American hornbeam 1
Celtis laevigata - sugarberry 1
Cercis reniformis 'Oklahoma' - 'Oklahoma' Oklahoma redbud 1
Cornus canadensis - bunchberry dogwood 1
Cornus mas 'Redstone' - 'Redstone' Cornelian cherry 1
Cornus x rutban 'Aurora' - 'Aurora' Dogwood 1
Corylus cornuta - beaked hazelnut 1
Cotinus 'Royal Purple' - 'Royal Purple' Smoketree 1
Crataegus 'Crimson Cloud' - 'Crimson Cloud' Hawthorn 1
Crataegus 'Lavellus' - 'Lavellus' Hawthorn 1
Eucommia ulmoides 'Emerald Pointe' - 'Emerald Pointe' Hardy rubber tree 1
Gymnocladus dioicus 'Prairie Titan' - 'Prairie Titan' Kentucky coffee tree 1
Halesia tetraptera - Common silverbell 1
Hamamelis vernalis - Ozark witchhazel 1
Lagerstroemia indica 'Tuskogee' - 'Tuskogee' Crapemyrtle 1
Malus 'Pink Spire' - 'Pink Spire' Crabapple 1
Malus 'Robinson' - 'Robinson' Crabapple 1
Malus x zumi var. calocarpa - Redbud crabapple 1
Malus x zumi var. calocarpa - Zumi crabapple 1
Nyssa sylvatica 'Tupelo Tower' - 'Tupelo Tower' Black gum 1
Oxydendrum arboreum - sourwood 1
Picea pungens 'Glauca' - 'Glauca' blue spruce 1
Populus - Poplar 1
Prunus 'Princeton Snowcloud' - 'Princeton Snowcloud' Sargent cherry 1
Prunus americana - American plum 1
Prunus armeniaca - Apricot 1
Prunus cistena 'Schmidt's' - 'Schmidt's' Purple-leaf sand cherry 1
Prunus serrulata 'Shirofugen' - 'Shirofugen' Japanese flowering cherry 1
Quercus laevis - turkey oak 1
Quercus marilandica - blackjack oak 1
Quercus nuttallii - Nuttall oak 1
Quercus phellos 'Upperton' - 'Upperton' Willow oak 1
Rhus typhina - Staghorn sumac 1
Sorbus hybrida - oakleaf mountain ash 1
Styrax americanus - American snowbell 1
Syringa meyeri 'Palibin' - 'Palibin' Korean lilac 1
Syringa pekinensis 'China Snow' - 'China Snow' Peking lilac 1
Syringa pekinensis 'Great Wall' - 'Great Wall' Peking lilac 1
Syringa reticulata 'Snowcap' - 'Snowcap' Japanese tree lilac 1
Taxodium distichum 'Skyward' - 'Skyward' Bald cypress 1
Thuja occidentalis 'George Peabody' - 'George Peabody' Arborvitae 1
Tilia cordata 'Unizam' - 'Unizam' Littleleaf linden 1
Tilia tomentosa 'Green Mountain' - 'Green Mountain' Silver linden 1
Ulmus parvifolia 'Bosque' - 'Bosque' Chinese elm 1





Show the code
#5. What is the species of the tree closest to Baruch’s campus?
baruch_longitude <- -73.9841
baruch_latitude  <- +40.7402

#CREATE A FUNCTION THAT TURNS GIVEN LATITUDE AND LONGITUDE COORDINATES INTO A GEOMPOINT
new_st_point <- function(lat, lon){
    # st_sfc expects x, y which flips the normal lat (N/S) + lon (W/E) ordering
    st_sfc(point = st_point(c(lon, lat))) |>
      st_set_crs("WGS84")
}

#CALLS ON FUNCTION TO CREATE GEOMPOINT FOR BARUCH 
my_point <- new_st_point(baruch_latitude, baruch_longitude)

library(units)

#FILTERS THROUGH DATA TO FIND ALL TREES 100 METERS FROM BARUCH
trees_near_baruch <- tree_sf_df |>
  mutate(distance = st_distance(geometry, my_point)) |>
  filter(distance < set_units(100, "m")) |> 
  arrange(distance)
Warning: Using one column matrices in `filter()` was deprecated in dplyr 1.1.0.
ℹ Please use one dimensional logical vectors instead.

Trees Species Around Baruch College

Pyrus calleryana - Callery pear is the closets tree to Baruch College with a distance of 19.58 meters away.

Show the code
trees_near_baruch_table <- trees_near_baruch |>
  select(c('genusspecies', 'distance'))

kable(trees_near_baruch_table) |>
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) |>
  scroll_box(height = "400px") |>
  row_spec(which.min(trees_near_baruch$distance), background = "forestgreen", color = "white")
genusspecies distance
Pyrus calleryana - Callery pear 19.58055 [m]
Pyrus calleryana - Callery pear 22.78890 [m]
Quercus acutissima - sawtooth oak 26.52277 [m]
Tilia cordata - littleleaf linden 26.95633 [m]
Pyrus calleryana - Callery pear 27.37608 [m]
Quercus imbricaria - shingle oak 32.03176 [m]
Quercus acutissima - sawtooth oak 32.03176 [m]
Pyrus calleryana - Callery pear 32.72946 [m]
Tilia tomentosa 'Sterling' - 'Sterling' Silver linden 32.72946 [m]
Pyrus calleryana - Callery pear 32.93093 [m]
Quercus acutissima - sawtooth oak 36.62256 [m]
Pyrus calleryana - Callery pear 39.60908 [m]
Tilia cordata - littleleaf linden 40.13246 [m]
Pyrus calleryana - Callery pear 46.50556 [m]
Zelkova serrata - Japanese zelkova 58.15175 [m]
Carpinus betulus - European hornbeam 58.15175 [m]
Acer truncatum 'Urban Sunset' - 'Urban Sunset' Shantung maple 58.15175 [m]
Tilia americana - American basswood 58.84170 [m]
Pyrus calleryana - Callery pear 60.74751 [m]
Betula nigra - river birch 60.74751 [m]
Pyrus calleryana - Callery pear 62.26635 [m]
Pyrus calleryana - Callery pear 64.73203 [m]
Betula nigra - river birch 64.73203 [m]
Pyrus calleryana - Callery pear 67.93458 [m]
Zelkova serrata - Japanese zelkova 68.14806 [m]
Quercus acutissima - sawtooth oak 70.24295 [m]
Tilia americana - American basswood 71.82338 [m]
Pyrus calleryana - Callery pear 71.88274 [m]
Zelkova serrata - Japanese zelkova 73.92391 [m]
Gleditsia triacanthos - Honeylocust 74.42669 [m]
Betula nigra - river birch 75.39107 [m]
Liquidambar styraciflua - sweetgum 82.14737 [m]
Pyrus calleryana - Callery pear 83.91028 [m]
Gleditsia triacanthos var. inermis - Thornless honeylocust 85.22978 [m]
Pyrus calleryana - Callery pear 86.24004 [m]
Gleditsia triacanthos var. inermis - Thornless honeylocust 87.48515 [m]
Gleditsia triacanthos var. inermis - Thornless honeylocust 87.58768 [m]
Ginkgo biloba - maidenhair tree 89.64937 [m]
Zelkova serrata - Japanese zelkova 89.82117 [m]
Pyrus calleryana - Callery pear 91.09238 [m]
Liquidambar styraciflua - sweetgum 91.09238 [m]
Liquidambar styraciflua - sweetgum 92.82713 [m]
Pyrus calleryana - Callery pear 93.47762 [m]
Pyrus calleryana - Callery pear 93.91617 [m]
Tilia americana - American basswood 95.14457 [m]
Pyrus calleryana - Callery pear 96.81250 [m]
Gleditsia triacanthos var. inermis - Thornless honeylocust 97.64237 [m]
Pyrus calleryana - Callery pear 97.67213 [m]
Pyrus calleryana - Callery pear 97.74690 [m]
Gleditsia triacanthos var. inermis - Thornless honeylocust 97.74690 [m]
Gleditsia triacanthos var. inermis - Thornless honeylocust 99.53155 [m]
Pyrus calleryana - Callery pear 99.94814 [m]


Fun Fact: Callery pear trees are classified as an invasive species in some states, and have been banned from planting because they tend to outcompete native species.

Trees Within 100-Meter Radius of Baruch College

Show the code
#CREATE A MAP TO LOCATE BARUCH AND TREES WITHIN A 100 METERS
leaflet() |>
  addTiles() |>
  addCircleMarkers(data = trees_near_baruch$geometry, radius = 10, color = "forestgreen", stroke = FALSE, fillOpacity =2) |>
  addCircleMarkers(data=my_point, radius=3, color="blue") |>
  addPopups(baruch_longitude, baruch_latitude, 
            "<b>Baruch College</b>") |>
  setView(baruch_longitude, baruch_latitude, zoom=100)

TASK 5: NYC PARKS PROPOSAL

Branching Out for a Healthier District 5

Council District 5 Neighborhoods Served: Upper East Side (Lenox Hill, Yorkville, Carnegie Hill) and Roosevelt Island

Overview:

Overall, New York City has maintained a healthy tree canopy, with relatively few trees classified as dead or in critical condition compared to the majority are rated as fair, good, or excellent. The bar graphs below depict the distribution of trees within each category.

Show the code
nyc_df_bargraph <- nyc_trees_df |>
  group_by(CounDist, tpcondition) |>
  summarize(category_count = n())

ggplot(nyc_df_bargraph, aes(x = tpcondition, y = category_count, fill = tpcondition)) +
  geom_col() +
  facet_wrap(~ CounDist,scales = "free_y") +
  labs(
    title = "Tree Condition Counts by NYC Council District",
    x = "Tree Condition",
    y = "Count"
  ) +
  theme_bw() +
  theme(
    axis.text.x = element_blank(),
    axis.ticks.x = element_blank(),
    text = element_text(size = 7),          # GLOBAL SMALLER FONT
    strip.text = element_text(size = 5),    # FACET LABELS SMALLER
    legend.text = element_text(size = 5),
    legend.title = element_text(size = 7)
  ) +
scale_fill_manual(
  name = "Condition",
  values = c(
    "Critical" = "red",
    "Dead" = "tomato",
    "Excellent" = "#39FF14",
    "Fair" = "forestgreen",
    "Good" = "yellow",
    "Poor" = "orange",
    "Unknown" = "gray"
  ),
  labels = c(
    "Critical" = "Critical",
    "Dead" = "Dead",
    "Excellent" = "Excellent",
    "Fair" = "Fair",
    "Good" = "Good",
    "Poor" = "Poor",
    "Unknown" = "Unknown"
  )
)

An aerial view of our tree canopy shows a healthy spread of fair, good, excellent trees with minimal scattering of dead and in critical condition trees.

Show the code
cd5 <- nyc_trees_df |>
  filter(CounDist == 5)

cd5_point <- left_join(cd5, tree_sf_df, by = c("objectid", "dbh", "tpstructure", "tpcondition", "plantingspaceglobalid", "globalid", "genusspecies", "createddate", "updateddate", "riskrating", "riskratingdate", "planteddate", "stumpdiameter"))

library(ggplot2)

ggplot() +
  geom_sf(data = cd5_point, aes(geometry = geometry.x), color = "black") +
  geom_sf(data = cd5_point, aes(geometry = geometry.y, color = tpcondition),
          size = 0.5, alpha=0.3) +
  scale_color_manual(values = c(
    "Critical" = "red",
    "Dead" = "tomato",
    "Excellent" = "#39FF14",
    "Fair" = "forestgreen",
    "Good" = "yellow",
    "Poor" = "orange",
    "Unknown" = "gray"
  )) +
  theme_minimal()

A closer quantitative assessment was conducted to compare the ratios by district of poor to acceptable tree conditions. Where poor conditions include dead and critical trees, while acceptable trees include fair, good, and excellent trees. For the purpose of this assessment, tree conditions labeled as “unknown” were neglected. A higher ratio indicates that a district requires more support to tend to dead and critical trees. District 5 ranks 18th out of 51 for the highest ratio, putting us in the 66th percentile, which we plan to improve upon.

Show the code
library(dplyr)

ratio <- nyc_trees_df |>
  group_by(CounDist) |>
  summarise(
    bad_count = sum(tpcondition %in% c("Dead", "Critical"), na.rm = TRUE),
    good_count = sum(tpcondition %in% c("Fair", "Good", "Excellent"), na.rm = TRUE),
    ratio = bad_count / good_count,
    .groups = "drop"
  ) |>
  arrange(desc(ratio))


Poor to Adequate Tree Condition Ratio by Council District

Show the code
kable(ratio) |>
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) |>
  scroll_box(height = "400px") |>
  row_spec(which(ratio$CounDist == 5), background = "forestgreen", color = "white")
CounDist bad_count good_count ratio
32 4565 23000 0.1984783
30 3380 17593 0.1921219
50 7640 41509 0.1840565
49 4928 27789 0.1773364
29 2799 15862 0.1764595
2 1637 9318 0.1756815
23 6179 35245 0.1753156
19 6761 39114 0.1728537
51 9880 57445 0.1719906
11 3794 22088 0.1717675
20 2819 16440 0.1714720
16 1820 10936 0.1664228
24 3431 20994 0.1634276
13 4765 29605 0.1609525
27 3799 23618 0.1608519
28 3251 20286 0.1602583
14 1402 8867 0.1581144
5 1048 6774 0.1547092
10 1893 12272 0.1542536
25 1243 8114 0.1531920
22 2218 14578 0.1521471
1 1520 10080 0.1507937
4 1365 9100 0.1500000
17 2312 15506 0.1491036
15 2240 15365 0.1457859
3 1428 9882 0.1445052
31 3576 25108 0.1424247
9 1577 11161 0.1412956
8 1962 15065 0.1302356
7 1670 12916 0.1292970
12 1743 13510 0.1290155
34 1664 13016 0.1278427
26 1627 12778 0.1273282
18 1761 14662 0.1201064
6 1134 10427 0.1087561
38 1463 13598 0.1075894
48 1523 14605 0.1042794
37 1345 12928 0.1040377
21 1632 16029 0.1018155
47 1776 17463 0.1017007
42 1526 16024 0.0952322
45 1343 14159 0.0948513
39 2489 26935 0.0924076
33 1464 16043 0.0912548
40 905 10044 0.0901035
44 1306 14591 0.0895072
35 1089 12720 0.0856132
43 743 8929 0.0832120
41 1011 12424 0.0813748
36 889 11799 0.0753454
46 1509 20227 0.0746033

Issue:

Our main concern is that we are ranking the lowest in tree diversity, with only 198 unique tree species. Coming in close were our neighbors in Districts 4 and 6, with 200 and 220 unique tree species, respectively. In contrast, District 13, with the highest of 392 unique tree species, nearly doubles our count.

Show the code
#COUNCIL DISTRICT 5 HAS THE LEAST DIVERSITY IN TREE SPECIES  
tree_diversity <- nyc_trees_df |> 
   group_by(CounDist) |> 
   summarize(number_of_species = n_distinct(genusspecies)) |> 
   arrange(number_of_species) 


Tree Diversity by Council District

Show the code
kable(tree_diversity) |>
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) |>
  scroll_box(height = "400px") |>
  row_spec(which(tree_diversity$CounDist == 5), background = "tomato", color = "black")
CounDist number_of_species
5 198
4 200
6 220
25 224
43 229
3 238
10 242
7 252
9 253
35 253
1 257
26 263
14 264
40 266
36 267
2 270
16 273
20 273
21 275
38 279
41 285
42 286
22 287
37 287
24 289
34 290
12 291
18 291
33 291
17 298
44 298
45 298
48 303
46 304
8 306
47 308
31 314
29 315
39 315
30 322
15 332
28 332
27 333
23 340
51 352
11 353
49 367
32 368
50 374
19 382
13 392

Proposal & Methodology:

To address our two main issues, we will assess trees in poor condition to determine which ones are salvageable and which must be removed. In replacement, new tree species will be planted to lower our poor to adequate tree condition ratio and increase our tree diversity. We’ll also be taking volunteers to bring our vision to life, so join us to make District 5 greener!

Pros Setbacks
• An increase in biodiversity makes the environment less susceptible to diseases • Costly reparations
• Visual appeal of removing dead trees • Timely procedure
• Improved air quality • Pest control